package com.lyj.utils;

import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class DateUtil {

	//从长整形转换成字符串格式的日期
	public static String toShortDate(Long time) {
		SimpleDateFormat df= new SimpleDateFormat("yyyy年MM月dd日");
		return df.format(new Date(time));
	}
	
	public static String toLongDate(Long time) {
		SimpleDateFormat df= new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss");
		return df.format(new Date(time));
		
	}
	
	public static Long toLong(String time) throws ParseException {
		SimpleDateFormat df= new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss");
		return df.parse(time).getTime();
	}
	
	public static Long nowToLong() throws ParseException {
		Date date = new Date();
		SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss");	
		String now = format.format(date);
		return format.parse(now).getTime();
	}
}
